package com.telit.common.util;

/**
 * @Author:zhangwei
 * @Description:文件校验工具类
 * @Time:Created on 2021/10/2 8:23
 */
public class FileTypeCheckUtils {

    /**
     * 校验excel后缀
     * @param fileName
     * @return
     */
    public static boolean checkExcel(String fileName){
        if (fileName == null || fileName.length() == 0) {
            return true;
        }
        if (!fileName.endsWith(".xls") && !fileName.endsWith(".xlsx")) {
            return true;
        }
        return false;
    }

    /**
     * 校验zip文件后缀名
     * @param fileName
     * @return
     */
    public static boolean checkZip(String fileName){
        if (fileName == null || fileName.length() == 0) {
            return true;
        }
        if (!fileName.endsWith(".zip")) {
            return true;
        }
        return false;
    }

    /**
     * 校验pdf文件
     * @param fileName
     * @return
     */
    public static boolean checkPdf(String fileName){
        if (fileName == null || fileName.length() == 0) {
            return true;
        }
        if (!fileName.endsWith(".pdf")) {
            return true;
        }
        return false;
    }

    /**
     * 校验word文件后缀名
     * @param fileName
     * @return
     */
    public static boolean checkWord(String fileName){
        if (fileName == null || fileName.length() == 0) {
            return true;
        }
        if (!fileName.endsWith(".doc") && !fileName.endsWith(".docx")) {
            return true;
        }
        return false;
    }

}
